agent: @U0AJM7X8FBR Admin + Docs + API - we want to update the /coding page in #21
Conversation
- Add pull_requests: string[] to SlackTag type - Update getTagsByDate to track pull_request_count per date - Update AdminLineChart to support an optional second line (PRs) - Add Pull Requests column to SlackTagsTable - Wire chart and table to show tags vs PRs over time Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe diff adds pull-request tracking to the Slack tags admin UI: types and aggregation now include PR counts, the tags page shows PR metrics and a new "Pull Requests" column, and AdminLineChart gains an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant Page as CodingAgentSlackTagsPage
participant Lib as getTagsByDate
participant Chart as AdminLineChart
Browser->>Page: Request tags data (API)
Page->>Lib: getTagsByDate(tags[])
Lib-->>Page: [{date, count, pull_request_count}...]
Page->>Chart: Render with primary series + secondLine (if pull_request_count > 0)
Chart-->>Browser: Draw mergedData with count and count2 series
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… type and UI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx (1)
75-86: Avoid computinggetTagsByDatetwice.
getTagsByDate(data.tags)is called twice with identical input—once for the primary series and once forsecondLine. Consider computing it once.♻️ Proposed refactor to compute once
{!isLoading && !error && data && data.tags.length > 0 && ( - <> + (() => { + const tagsByDate = getTagsByDate(data.tags); + return ( + <> - <AdminLineChart - title="Tags & Pull Requests Over Time" - data={getTagsByDate(data.tags).map((d) => ({ date: d.date, count: d.count }))} - label="Tags" - secondLine={{ - data: getTagsByDate(data.tags).map((d) => ({ - date: d.date, - count: d.pull_request_count, - })), - label: "Pull Requests", - }} - /> + <AdminLineChart + title="Tags & Pull Requests Over Time" + data={tagsByDate.map((d) => ({ date: d.date, count: d.count }))} + label="Tags" + secondLine={{ + data: tagsByDate.map((d) => ({ + date: d.date, + count: d.pull_request_count, + })), + label: "Pull Requests", + }} + /> - <SlackTagsTable tags={data.tags} /> - </> + <SlackTagsTable tags={data.tags} /> + </> + ); + })() )}Alternatively, extract the chart data preparation into a
useMemoat the top of the component.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx` around lines 75 - 86, Compute getTagsByDate(data.tags) once and reuse it for both series: call getTagsByDate(data.tags) into a single variable (or a useMemo) at the top of the component, then pass that cached result to AdminLineChart for the primary series and to secondLine.data (mapping to pull_request_count) instead of calling getTagsByDate twice; update references to getTagsByDate in the AdminLineChart props to use the new variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/CodingAgentSlackTags/SlackTagsColumns.tsx`:
- Around line 53-62: In SlackTagsColumns where prs is rendered, the regex
url.match(/\/pull\/(\d+)/) can return undefined and produce "#undefined"; fix by
extracting the match into a variable (e.g., const prMatch =
url.match(/\/pull\/(\d+)/)) and render a safe fallback: if prMatch exists render
`#${prMatch[1]}` otherwise render a sensible fallback such as the original url
or a label like "View PR" (keep the same anchor href and key to preserve
uniqueness). Ensure this change is applied inside the map callback that renders
the <a> for prs so non-matching URLs no longer show "#undefined".
---
Nitpick comments:
In `@components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx`:
- Around line 75-86: Compute getTagsByDate(data.tags) once and reuse it for both
series: call getTagsByDate(data.tags) into a single variable (or a useMemo) at
the top of the component, then pass that cached result to AdminLineChart for the
primary series and to secondLine.data (mapping to pull_request_count) instead of
calling getTagsByDate twice; update references to getTagsByDate in the
AdminLineChart props to use the new variable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 273a2a2c-87eb-4995-b053-1dd8dec543c9
📒 Files selected for processing (5)
components/Admin/AdminLineChart.tsxcomponents/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsxcomponents/CodingAgentSlackTags/SlackTagsColumns.tsxlib/coding-agent/getTagsByDate.tstypes/coding-agent.ts
…n PR column Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx (1)
75-85: Avoid duplicategetTagsByDateaggregation in render.Line 77 and Line 80 recompute the same grouped series. Compute once and reuse for both lines to reduce repeated work and keep chart wiring easier to maintain.
♻️ Proposed refactor
export default function CodingAgentSlackTagsPage() { const [period, setPeriod] = useState<AdminPeriod>("all"); const { data, isLoading, error } = useSlackTags(period); + const tagsByDate = data ? getTagsByDate(data.tags) : []; return ( @@ <AdminLineChart title="Tags & Pull Requests Over Time" - data={getTagsByDate(data.tags).map((d) => ({ date: d.date, count: d.count }))} + data={tagsByDate.map((d) => ({ date: d.date, count: d.count }))} label="Tags" secondLine={{ - data: getTagsByDate(data.tags).map((d) => ({ + data: tagsByDate.map((d) => ({ date: d.date, count: d.pull_request_count, })), label: "Tags with PRs", }} />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx` around lines 75 - 85, The render currently calls getTagsByDate(data.tags) twice when building the AdminLineChart props; compute const tagsByDate = getTagsByDate(data.tags) once above the JSX and reuse tagsByDate.map(...) for both the primary line and the secondLine data to avoid duplicate aggregation and make the AdminLineChart wiring (props: title, data, label, secondLine) clearer and cheaper to render.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/coding-agent/getTagsByDate.ts`:
- Around line 20-23: The pull_request_count currently increments by 1 per tag
regardless of how many PRs are referenced; change the increment in the block
that updates counts (where counts[date] is initialized and modified) to add the
actual number of PRs referenced by the tag (use tag.pull_requests?.length or 0)
instead of always adding 1 so pull_request_count reflects total PR links for
that date.
---
Nitpick comments:
In `@components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx`:
- Around line 75-85: The render currently calls getTagsByDate(data.tags) twice
when building the AdminLineChart props; compute const tagsByDate =
getTagsByDate(data.tags) once above the JSX and reuse tagsByDate.map(...) for
both the primary line and the secondLine data to avoid duplicate aggregation and
make the AdminLineChart wiring (props: title, data, label, secondLine) clearer
and cheaper to render.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 81d31782-a4f8-41c1-abd5-0b66e2fa6454
📒 Files selected for processing (3)
components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsxcomponents/CodingAgentSlackTags/SlackTagsColumns.tsxlib/coding-agent/getTagsByDate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- components/CodingAgentSlackTags/SlackTagsColumns.tsx
| if (!counts[date]) counts[date] = { count: 0, pull_request_count: 0 }; | ||
| counts[date].count += 1; | ||
| counts[date].pull_request_count += (tag.pull_requests?.length ?? 0) > 0 ? 1 : 0; | ||
| } |
There was a problem hiding this comment.
pull_request_count is currently counting tags, not pull requests.
At Line 22, this adds 1 per tagged message with any PR. That undercounts days where a message includes multiple PR links and conflicts with “pull requests over time” semantics.
🔧 Proposed fix
- counts[date].pull_request_count += (tag.pull_requests?.length ?? 0) > 0 ? 1 : 0;
+ counts[date].pull_request_count += tag.pull_requests?.length ?? 0;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!counts[date]) counts[date] = { count: 0, pull_request_count: 0 }; | |
| counts[date].count += 1; | |
| counts[date].pull_request_count += (tag.pull_requests?.length ?? 0) > 0 ? 1 : 0; | |
| } | |
| if (!counts[date]) counts[date] = { count: 0, pull_request_count: 0 }; | |
| counts[date].count += 1; | |
| counts[date].pull_request_count += tag.pull_requests?.length ?? 0; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/coding-agent/getTagsByDate.ts` around lines 20 - 23, The
pull_request_count currently increments by 1 per tag regardless of how many PRs
are referenced; change the increment in the block that updates counts (where
counts[date] is initialized and modified) to add the actual number of PRs
referenced by the tag (use tag.pull_requests?.length or 0) instead of always
adding 1 so pull_request_count reflects total PR links for that date.
Automated PR from coding agent.
Prompt: @U0AJM7X8FBR Admin + Docs + API - we want to update the /coding page in the admin codebase to view analytics around pull requests opened by the coding-agent.
• What is the link to the pull request opened?
• Which codebase was the pull request opened in?
• What was the original prompt which triggered the Agent to open this pull request?
Implementation details
• Docs - update the existing endpoint GET /api/admins/coding/slack - documentation-driven development.
• API - implement the endpoint to follow the updated docs.
• Admin - update the existing /coding page to display the new info
Summary by CodeRabbit